package hbt;

import model.Categoria;
import model.Diccionario;
import model.EstadoTema;
import model.ItemDiccionario;
import model.Moderador;
import model.Ranking;
import model.Tema;
import model.Usuario;
import model.Miembro;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;


 
public class HibernateUtil
{
    private static final SessionFactory sessionFactory;
    static
    {
        try
        {
        	 AnnotationConfiguration config = new AnnotationConfiguration();
        	 config.addAnnotatedClass(Categoria.class);
        	 config.addAnnotatedClass(Usuario.class);
        	 config.addAnnotatedClass(Diccionario.class);
        	 config.addAnnotatedClass(EstadoTema.class);
        	 config.addAnnotatedClass(ItemDiccionario.class);
        	 config.addAnnotatedClass(Tema.class);
        	 config.addAnnotatedClass(Miembro.class);
        	 config.addAnnotatedClass(Moderador.class);
        	 //config.addAnnotatedClass(RankingID.class);
        	 config.addAnnotatedClass(Ranking.class);
        	 
             sessionFactory = config.buildSessionFactory();
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed. " + ex);
             throw new ExceptionInInitializerError(ex);
        }
    }
 
    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}
